package com.ruibang.glass.material.controller.rqgl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.ruibang.glass.material.domain.req.rq.ATypeWaterReq;
import com.ruibang.glass.material.entity.rq.MaterialStatusManagement;
import com.ruibang.glass.material.service.rq.MaterialStatusManagementService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 容器状态管理 前端控制器
 * </p>
 *
 * @author mameng
 * @since 2024-02-05
 */


@Api(tags = "容器状态管理")
@RestController
@RequestMapping("/api/glass/material/status/management")
public class MaterialStatusManagementController {


    @Autowired
    private MaterialStatusManagementService materialContainerStaleStatisticsService;

    @PostMapping("/list")
    @ApiOperation(value = "获取列表信息", response = ResultBody.class)
    public ResultBody getPageList(@RequestBody ATypeWaterReq containerStalesReq) {
        return ResultBody.success(materialContainerStaleStatisticsService.getPage(containerStalesReq));
    }

    @PostMapping("/add")
    @ApiOperation(value = "获取列表信息", response = ResultBody.class)
    public ResultBody addMaterialStatusManagement(@RequestBody MaterialStatusManagement materialStatusManagement) {
        return ResultBody.success(materialContainerStaleStatisticsService.save(materialStatusManagement));
    }

    @PostMapping("/update")
    @ApiOperation(value = "获取列表信息", response = ResultBody.class)
    public ResultBody updateMaterialStatusManagement(@RequestBody MaterialStatusManagement materialStatusManagement) {
        return ResultBody.success(materialContainerStaleStatisticsService.updateById(materialStatusManagement));
    }

    @GetMapping("/remove/{id}")
    @ApiOperation(value = "获取列表信息", response = ResultBody.class)
    public ResultBody updateMaterialStatusManagement(@PathVariable("id") String id) {
        materialContainerStaleStatisticsService.removeMaterialStatusById(id);
        return ResultBody.success();
    }

    @GetMapping("/getRqSelectList")
    @ApiOperation(value = "容器下拉", response = ResultBody.class)
    public ResultBody getRqSelectList() {
        return ResultBody.success(materialContainerStaleStatisticsService.list(Wrappers.<MaterialStatusManagement>lambdaQuery()
                .select(MaterialStatusManagement::getId, MaterialStatusManagement::getContainerStatusName)));
    }


}
